importPackage(Packages.aurelienribon.tweenengine);
importPackage(Packages.aurelienribon.tweenengine.equations);

var Timeline=Packages.aurelienribon.tweenengine.Timeline;
var Tween=Packages.aurelienribon.tweenengine.Tween;
var Linear=Packages.aurelienribon.tweenengine.equations.Linear.INOUT;

var scheduler=new Object();
scheduler.getSize=function(stage){
	return stage.getMissileCount();
}

scheduler.getTimes=function(stage){
	var counter=0;
	var result=new Array();
	for(var i=0;i<this.getSize(stage);i++){
		result.push(counter);
		counter+=0.5;
	}
	return result;
}

scheduler.getParameters=function(stage){
	return new Array();
}

scheduler.getMethods=function(stage){
	var result=new Array();
	for(var i=0;i<this.getSize(stage);i++){
		result.push("step1");
	}
	return result;
}

scheduler.step1=function(stage){
	
	var y0=stage.getTrackOffset();
	
	var y=Math.random()*200+50+y0;
	
	var createJump=function(t,x,y,r){
		return Tween.to(t,1,1).target(x-2*r,y).waypoint(x-r,y+r);
	}

	var createTimeline=function(t){
		var timeline=Timeline.createSequence().beginSequence();
		var radius=100;
		for(var x=1100;x>-20;x-=2*radius){
			timeline.push(createJump(t,x,y,radius));
		}
		timeline.end();
		
		return timeline;
	}
	
	
	// create an actor that rushes to other player
	var actor=stage.createSpecialMissileActor();
	actor.setMissileType(1);
	actor.setModelPosition(1100,y0);
	
	stage.tweenSpecialMissileActor(actor,createTimeline(actor));
	
	// create virtual actor for prediction
	var virtualActor=stage.createVirtualSpecialMissileActor(actor);
	virtualActor.setPosition(1100,y0);
	stage.tweenVirtualSpecialMissileActor(virtualActor,createTimeline(virtualActor));
	
}
